package capricornus.utils
{
	import capricornus.components.utils.color.Color;
	import capricornus.core.StageManager;
	
	import flash.display.Bitmap;
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.ColorTransform;
	import flash.geom.Rectangle;
	import flash.utils.setTimeout;
	
	public class SpriteUtils
	{
		public function SpriteUtils()
		{
		}
		
		public static function getSprite( w:Number=10, h:Number=10, color:Number=0xffffff ):Sprite
		{
			var s:Sprite = new Sprite();
			s.graphics.beginFill( color );
			s.graphics.drawRoundRect( 0, 0, w, h, 0, 0 );
			s.graphics.endFill();
			
			return s;
		}
		
		public static function changeColor( dis:DisplayObject, color:uint ):void
		{
			var ct:ColorTransform = dis.transform.colorTransform;
			var c:Color = Color.getRGB( color );
		
			ct.alphaMultiplier = 0;
			ct.alphaOffset = c.a;
			ct.redMultiplier = 0;
			ct.redOffset = c.r;
			ct.blueMultiplier = 0;
			ct.blueOffset = c.b;
			ct.greenMultiplier = 0;
			ct.greenOffset = c.g;
			
			dis.transform.colorTransform = ct;
		}
	}
}